<?php
if ($_GET['del_szab']<>''){
$sql="delete from sl_szablony where id =".$_GET['del_szab'];
mysql_query($sql);
}
if ($_POST['wiz_szablon']) {
	foreach ($_POST['wiz_szablon'] as $i => $w){
		$_SESSION['s']=$i;
	}
}
$s=$a;
$sql="select * from sl_szablony where akt=1 and id_gab = ".$_SESSION['wyb_gab'];

if ($s=='b') {
$sql.=" and typ = 'b'";
$_SESSION['wiz_skad']='wiz_badanie';
}

if ($s=='w') {
$sql.=" and typ = 'w'";
$_SESSION['wiz_skad']='wiz_badanie';
}

if ($s=='z') {
$sql.=" and typ = 'z'";
$_SESSION['wiz_skad']='wiz_zalecenia';
}

if ($s=='c') {
$sql.=" and typ = 'c'";
$_SESSION['wiz_skad']='wiz_zalecenia';
}

$sql=$sql." order by id desc";
#echo $sql;
$result=mysql_query($sql);
echo '<table align="center" width="90%">';
echo '<tr><td>';
 echo '<form action="index.php" method=POST>';
    echo '<input type=submit value="Dodaj szablon" name="dod_szablon['.$s.']" class="butt">';
    echo '</form>';
echo '</td></tr>';
while($row = mysql_fetch_array($result))
{
echo '<tr><td class="linia"><div id='.$row[0].' class="';
if ($s=='w') echo 'szab_wyw';
elseif ($s=='b') echo 'szab_bad';
elseif ($s=='c') echo 'szab_badc';
elseif ($s=='z') echo 'szab_zal';
echo '">'.$row[1].'</div></a></td><td class="linia" align="ringht"><a href="index.php?del_szab='.$row[0].'"><img src="./img/del.png"></a></tr>';
}

echo '</table>';
?>
